Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Added date time parsing for conditional formatting #1120

Merged
merged 3 commits into from
Mar 2, 2023

Conversation

bmingles
Copy link
Contributor

@bmingles bmingles commented Mar 1, 2023

Added datetime string parsing / validation.

fixes #1108

vbabich
vbabich previously approved these changes Mar 1, 2023
// Proper date validation will be addressed by Issue #1108
return value != null && value !== '';
default: {
const [dt, tz] = (value ?? '').split(' ');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One suggestion - use camel case and full words for variable names. We try to follow the Airbnb style guide – https://github.com/airbnb/javascript#naming-conventions
with a few exceptions. e as the catch block argument is fine, single-character names in loops and maps are also fine, as long as the loop body is fairly short.

In this case, these are local variables and the scope is short so it's probably fine, but I thought I'd mentioned this anyway.

@codecov
Copy link

codecov bot commented Mar 1, 2023

Codecov Report

Merging #1120 (0b98b7d) into main (4ed5787) will increase coverage by 0.01%.
The diff coverage is 100.00%.

❗ Current head 0b98b7d differs from pull request most recent head cc2c1c2. Consider uploading reports for the commit cc2c1c2 to get more accurate results

@@            Coverage Diff             @@
##             main    #1120      +/-   ##
==========================================
+ Coverage   43.37%   43.39%   +0.01%     
==========================================
  Files         434      434              
  Lines       32617    32626       +9     
  Branches     8218     8218              
==========================================
+ Hits        14148    14157       +9     
  Misses      18420    18420              
  Partials       49       49              
Flag Coverage Δ
unit 43.39% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...nditional-formatting/ConditionalFormattingUtils.ts 29.15% <100.00%> (+1.57%) ⬆️
...udio/src/settings/ColumnSpecificSectionContent.tsx 98.73% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

vbabich
vbabich previously approved these changes Mar 1, 2023
// Proper date validation will be addressed by Issue #1108
return value != null && value !== '';
default: {
const [dateTimeString, tzCode] = (value ?? '').split(' ');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would 2023-02-23T11:46:31.000000000 NY FOO pass validation but still fail server size?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.
Also, a dateTime string can have a space in place of the t-separator: 2023-02-23 11:46:31.000000000 NY.
Regex for the separator in DateUtils/parseDateTimeString looks like this: [tT\s].

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore my comment, looks like the engine expects a T in format conditions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if we could accepted strings anywhere in the UI that takes a datetime with or without the T separator, then normalize it before sending.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, also accept datetime with or without the time zone. Should default to the time zone in the user settings. That would be another ticket though.

@bmingles bmingles force-pushed the 1108-conditional-date-formatting branch from a332ccf to cc2c1c2 Compare March 2, 2023 16:44
@bmingles
Copy link
Contributor Author

bmingles commented Mar 2, 2023

@vbabich It was suggested by @niloc132 that instead of using convertDateTime, we could use autoEpochToNanos in the Java expression that gets run by the engine. This would require us to parse the datetime in the UI first and then use the nanos value in the expression. This "should" address the issue we still have with the engine only supporting a subset of timezones.

I'm hesitant to do that for this issue given the current solution is already implemented, but I can create a new issue if we think this is a better solution.

@vbabich
Copy link
Collaborator

vbabich commented Mar 2, 2023

@bmingles Agreed, open another issue for this.

@bmingles bmingles merged commit 4c7710e into deephaven:main Mar 2, 2023
@bmingles bmingles deleted the 1108-conditional-date-formatting branch March 2, 2023 17:45
@github-actions github-actions bot locked and limited conversation to collaborators Mar 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Conditional formatting errors when setting an invalid date string
3 participants